.NET: Support returning durable workflow results from HTTP trigger endpoint#5321
Merged
.NET: Support returning durable workflow results from HTTP trigger endpoint#5321
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in “wait for completion” mode to the Azure Functions HTTP workflow trigger so callers can synchronously receive workflow results (plain text by default, JSON when Accept: application/json is provided), along with docs, samples, and an integration test update.
Changes:
- Add
x-ms-wait-for-responsesupport for workflow HTTP trigger and refactor shared header parsing helpers. - Add synchronous completion wait path that returns
200 OKwith either plain text or structured JSON (runId,status,result). - Update samples/docs and add an end-to-end integration test for the new header behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctions.cs | Implements wait-for-completion HTTP response path and consolidates header parsing helpers. |
| dotnet/tests/Microsoft.Agents.AI.Hosting.AzureFunctions.IntegrationTests/WorkflowSamplesValidation.cs | Adds an integration test covering the wait-for-response header for workflows. |
| dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/CHANGELOG.md | Adds an Unreleased changelog entry for the new HTTP trigger behavior. |
| dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/01_SequentialWorkflow/demo.http | Adds request examples demonstrating wait-for-response (plain text + JSON). |
| dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/01_SequentialWorkflow/README.md | Documents how to wait for workflow results and request JSON responses. |
cgillum
reviewed
Apr 18, 2026
- Return 404 Not Found when no orchestration with the given ID exists - Return 200 OK for failed workflows (the HTTP operation succeeded; the workflow outcome is conveyed via the response body) - Rename 'status' to 'workflowStatus' in WorkflowRunResponse to avoid inconsistency with AgentRunSuccessResponse which uses integer status - Add optional 'error' field (omitted from JSON when null) to WorkflowRunResponse for failed workflow details
cgillum
approved these changes
Apr 21, 2026
ahmedmuhsin
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for synchronously returning workflow execution results from the HTTP trigger endpoint. By default, the workflow HTTP endpoint fires-and-forgets (202 Accepted). With this change, callers can set the
x-ms-wait-for-response: trueheader to wait for the workflow to complete and receive the result directly in the HTTP response (200 OK). Results are returned as plain text by default, or as a structured JSON object whenAccept: application/jsonis specified.Changes
New feature
x-ms-wait-for-responseheader inRunWorkflowOrchestrationHttpTriggerAsyncWaitForWorkflowCompletionAsyncmethod that callsWaitForInstanceCompletionAsyncand handles failure/completed/unexpected statusesAccept: application/jsonheader to return a structured JSON response (runId,status,result)JsonElement) rather than double-encoded stringsCode quality improvements
WaitForResponseHeaderNameconstant (replaces two inline string literals)ShouldWaitForResponse(req, defaultValue)helper to eliminate duplicated header-parsing logic across workflow and agent triggersAcceptsJson(req)helper to deduplicateAcceptheader checks across 4 response methodsacceptsJsonparameter toCreateErrorResponseAsyncto avoid redundant header reads withinWaitForWorkflowCompletionAsyncDocs & samples
01_SequentialWorkflow/README.mdwith curl/PowerShell examples for the new headerTests
WorkflowSamplesValidation.csverifying the header works end-to-endJSON response examples
Plain text (default):
JSON (with
Accept: application/json):{ "runId": "abc123def456", "status": "Completed", "result": "Cancellation email sent for order 12345 to jerry@example.com." }JSON with POCO result (executor returns an object):
{ "runId": "abc123def456", "status": "Completed", "result": { "orderId": 123, "email": "jerry@example.com" } }Description
Contribution Checklist